home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Temperature / DDocData.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  1.1 KB  |  77 lines  |  [TEXT/CWIE]

  1. // DDocData.cp -- data container class for Temperature
  2.  
  3. #include "DDocData.h"
  4.  
  5. #include <LFileStream.h>
  6.  
  7.  
  8. //----------
  9. DDocData::DDocData ()
  10. {
  11.     mCentigrade = 10;
  12.     mFahrenheit = 50;
  13. }
  14.  
  15. //----------
  16. DDocData::~DDocData ()
  17. {
  18. }
  19.  
  20. //----------
  21. void    DDocData::CopyFrom (
  22.     DDocData*        inOther)
  23. {
  24.     mCentigrade = inOther->mCentigrade;
  25.     mFahrenheit = inOther->mFahrenheit;
  26. }
  27.  
  28. //----------
  29. void    DDocData::ReadFromFile (
  30.     LFileStream*    inFile)
  31. {
  32. }
  33.  
  34. //----------
  35. void    DDocData::WriteToFile (
  36.     LFileStream*    inFile)
  37. {
  38. }
  39.  
  40.  
  41. //----------
  42. SInt16        DDocData::GetCentigrade () const
  43. {
  44.  
  45.     return mCentigrade;
  46. }
  47.  
  48. //----------
  49. void    DDocData::SetCentigrade (
  50.     SInt16        inValue)
  51. {
  52.     mCentigrade = inValue;
  53.         mFahrenheit = ((18 * mCentigrade) + 5) / 10 + 32;
  54.     SignalDataChanged (idFahrenheit);
  55.  
  56.     SignalDataChanged (idCentigrade);
  57. }
  58.  
  59.  
  60. //----------
  61. SInt16        DDocData::GetFahrenheit () const
  62. {
  63.  
  64.     return mFahrenheit;
  65. }
  66.  
  67. //----------
  68. void    DDocData::SetFahrenheit (
  69.     SInt16        inValue)
  70. {
  71.     mFahrenheit = inValue;
  72.         mCentigrade = ((10 * (mFahrenheit - 32)) + 9) / 18;
  73.     SignalDataChanged (idCentigrade);
  74.  
  75.     SignalDataChanged (idFahrenheit);
  76. }
  77.